import React,{ Component } from "react";
import SortableTable from './SortableTable';
import * as rest from '../../lib/rest';

/**
 *  表格字段列表 可排序表格
 *  预计用于 可视化表格编辑 由前端选择操作 生成表格
 */
export default class TableFieldList extends Component {
    constructor(props){
        super(props)
        this.state={
            data : [],
            columns:[]
        }
    }
    
    componentDidMount () {
        rest.get(`/confTable/findAll`).then((recList)=>{
            this.setState({
                data : recList.map((item,index)=>{
                    return{
                        key:'index',
                        index:index,
                        ...item
                    }
                })
            })
        })
    }

    render() {
        
        const {data} = this.state;

        console.log(data);
        const columnsB = [
            {
            title: 'tableName',
            dataIndex: 'tableName',
            className: 'drag-visible',
            },
            {
            title: 'tableComment',
            dataIndex: 'tableComment',
            },
            {
            title: '1',
            dataIndex: 'tableComment',
            }
        ]
        return (
            <SortableTable 
                columnsB = {columnsB}
                dataSource = { data }
                data = {data}
            />
        );
        
       
  }
  
}

